#include <vector>
#include <algorithm>

using namespace std;

class Solution
{
public:
    int miceAndCheese(vector<int>& reward1, vector<int>& reward2, int k)
    {
        int ans = 0;
        int n = reward1.size();
        vector<int> diffs(n);
        for (int i = 0; i < n; i++)
        {
            ans += reward2[i];
            diffs[i] = reward1[i] - reward2[i];
        }
        sort(diffs.begin(), diffs.end());
        for (int i = 1; i <= k; i++)
        {
            ans += diffs[n - i];
        }
        return ans;
    }
};